import Vue from 'vue'
import VueRouter from 'vue-router'
import Main from '../views/Main.vue'
import Login from '../views/Login.vue'

const originPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login,
    children:[

    ]
  },
  {
    path: '/main',
    name: 'Main',
    component: Main,
    children: [{
        path: 'home',
        name: 'home',
        component: () => import('@/views/Home/Home')
      },
      {
        path: 'goods_manage',
        name: 'goodsManage',
        component: () => import('@/views/Goods/GoodsManage')
      },
      {
        path: 'user_manage',
        name: 'userManage',
        component: () => import('@/views/User/UserManage')
      },
      {
        path: 'hb_manage',
        name: 'hbManage',
        component: () => import('@/views/Hb/HbManage')
      },
      {
        path: 'order_log',
        name: 'orderLog',
        component: () => import('@/views/Log/OrderLog')
      },
      {
        path: 'search_es_log',
        name: 'searchEsLog',
        component: () => import('@/views/Log/SearchEsLog')
      },
      {
        path: 'serch_hb_log',
        name: 'searchHbLog',
        component: () => import('@/views/Log/SearchHbLog')
      },
      {
        path: 'user_log',
        name: 'userLog',
        component: () => import('@/views/Log/UserLog')
      },
    ]
  },

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
